Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Cleaner Condition Types & Reasons #1007

Merged
merged 11 commits into from
Jul 22, 2024

Conversation

bentito
Copy link
Contributor

@bentito bentito commented Jul 2, 2024

Description

Fixes: #996

Cleaner Condition Types & Reasons. See commit messages for coverage of this PR and its sync to the RFC recommendations. https://docs.google.com/document/d/1JWJxnDXM0X1JQ67ZIDx5j1ayb1d7ajrK_uSDDaz0G98

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@bentito bentito requested a review from a team as a code owner July 2, 2024 15:31
Copy link

netlify bot commented Jul 2, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit f678a7c
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/669e4e46518dfc0008abd4fa
😎 Deploy Preview https://deploy-preview-1007--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.93%. Comparing base (a0fca0d) to head (f678a7c).

Files Patch % Lines
...nternal/controllers/clusterextension_controller.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1007      +/-   ##
==========================================
+ Coverage   72.75%   72.93%   +0.17%     
==========================================
  Files          31       31              
  Lines        1883     1862      -21     
==========================================
- Hits         1370     1358      -12     
+ Misses        375      366       -9     
  Partials      138      138              
Flag Coverage Δ
e2e 56.68% <0.00%> (+0.32%) ⬆️
unit 44.41% <50.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bentito
Copy link
Contributor Author

bentito commented Jul 3, 2024

NB: go-apidiff is an expected failing test as we're intentionally removing API items pre-GA.

setStatusUnpackPending(ext, unpackResult.Message)
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
setStatusInstallFalseUnpackFailed(ext, unpackResult.Message)
setInstalledStatusConditionInstalledFalse(ext, "installation has not been attempted as unpack is pending")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installed=False is not always correct here. If we have previously installed a bundle, and now the unpack of the next bundle is pending, we still have an installed bundle.

The installation status and the bundle unpack status are not related to each other.

Copy link
Contributor Author

@bentito bentito Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, just setting the unpack as failed in 0306c9d

@@ -273,13 +273,12 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp

switch unpackResult.State {
case rukpaksource.StatePending:
setStatusUnpackPending(ext, unpackResult.Message)
setInstalledStatusConditionUnknown(ext, "installation has not been attempted as unpack is pending")
setStatusInstallFalseUnpackFailed(ext, unpackResult.Message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpack state is pending, but we're setting Unpacked=False, Failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well this was changed to acknowledge that we've switched to direct image registry and that as far as opr-ctrl is concerned we can't really be in an Unknown state, we're either failed or not. Perhaps we should just not process StatePending here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should write this code with specific knowledge of the underlying Source implementation. In theory, the source could be switched out to a different implementation that can return StatePending. I've been tinkering with an async direct image client, so this is not entirely hypothetical.

More broadly, I wonder if we even need an Unpacked condition type? I don't see it in the diagram in the RFC. The only reason we are unpacking a bundle is so that we can install it. So can we rollup unpacking status into Progressing and/or Installed conditions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's farther than the RFC went, but I think it's in the same spirit. I think we can roll it into TypeInstalled. I think TypeProgressing would actually be adding a new type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as noted above there is no TypeProgressing currently, if we want to eliminate TypeUnpacked in favor of TypeInstalled
@joelanford, these two helper methods encapsulate all the places changes would be needed:

func setStatusUnpackFailed(ext *ocv1alpha1.ClusterExtension, message string) {
	ext.Status.InstalledBundle = nil
	apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
		Type:               ocv1alpha1.TypeUnpacked,
		Status:             metav1.ConditionFalse,
		Reason:             ocv1alpha1.ReasonUnpackFailed,
		Message:            message,
		ObservedGeneration: ext.GetGeneration(),
	})
}

func setStatusUnpacked(ext *ocv1alpha1.ClusterExtension, message string) {
	apimeta.SetStatusCondition(&ext.Status.Conditions, metav1.Condition{
		Type:               ocv1alpha1.TypeUnpacked,
		Status:             metav1.ConditionTrue,
		Reason:             ocv1alpha1.ReasonUnpackSuccess,
		Message:            message,
		ObservedGeneration: ext.GetGeneration(),
	})
}

So on the fail case we'd want TypeInstalled as ConditionUnknown and same on the success case. The reason would be the difference. But I wonder if the success case is a bit odd: TypeInstalled is Uknown and the reason is Unpack success?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TypeInstalled should literally just be based on: "is there a helm release secret with status deployed? if so, Installed=True. If not "Installed=False". If there was an error looking up helm release secrets (other than "not found"), then "Installed=Unknown".

Nothing else should play into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #1027 to capture this need. I'd like to keep this PR limited to the RFC covered items.

@tmshort
Copy link
Contributor

tmshort commented Jul 12, 2024

@joelanford are you ok with this?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2024
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
Signed-off-by: Brett Tofel <btofel@redhat.com>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2024
Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2024
@tmshort tmshort added this pull request to the merge queue Jul 22, 2024
Merged via the queue into operator-framework:main with commit 58c5776 Jul 22, 2024
16 of 18 checks passed
perdasilva pushed a commit to LalatenduMohanty/operator-controller that referenced this pull request Aug 13, 2024
* Replace ReasonCreateDynamicWatchFailed w/ ReasonInstallationFailed

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove unused ReasonInstallationSucceeded

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Drop usage of ConditionUnknown on Pending Install

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove ReasonUnpackPending/InstallationsStatusUnk

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Update related TODO in ClusterExtension controller

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Rm InstalledStatus->nil on upack & add comment

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Align CRD for added Go doc on InstalledBundle

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Move comment on InstalledBundle field

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Commit manifest changes for godoc change

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Decouple bundle unpacking and installed statuses

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove unneeded unpack stage helper method

Signed-off-by: Brett Tofel <btofel@redhat.com>

---------

Signed-off-by: Brett Tofel <btofel@redhat.com>
perdasilva pushed a commit to kevinrizza/operator-controller that referenced this pull request Aug 13, 2024
* Replace ReasonCreateDynamicWatchFailed w/ ReasonInstallationFailed

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove unused ReasonInstallationSucceeded

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Drop usage of ConditionUnknown on Pending Install

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove ReasonUnpackPending/InstallationsStatusUnk

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Update related TODO in ClusterExtension controller

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Rm InstalledStatus->nil on upack & add comment

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Align CRD for added Go doc on InstalledBundle

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Move comment on InstalledBundle field

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Commit manifest changes for godoc change

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Decouple bundle unpacking and installed statuses

Signed-off-by: Brett Tofel <btofel@redhat.com>

* Remove unneeded unpack stage helper method

Signed-off-by: Brett Tofel <btofel@redhat.com>

---------

Signed-off-by: Brett Tofel <btofel@redhat.com>
@skattoju skattoju mentioned this pull request Sep 25, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement condition changes for operator-controller per RFC
5 participants